import getInstance from './instance'
// import {
//   Message
// } from 'element-ui'
const instance = getInstance()

// http request 拦截器
instance.interceptors.request.use(
  config => {
    return config
  },
  err => {
    return Promise.reject(err)
  }
)

instance.interceptors.response.use(
  res => {
    return res.data
  },
  err => {
    if ((err + '').search('timeout') !== -1) {
      // Message.error('请求超时')
    }
    if (err.response && err.response.data && err.response.data.msg) {
      // Message.error(err.response.data.msg)
    } else {
      console.error(err)
    }
    return Promise.reject(err.response)
  }
)

export default instance
